package com.lcm.springcloud.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Coder-lcm
 * @date 2020/10/31
 */
@RestController
@EnableBinding(Sink.class)  //消息的消费者
public class ReceiveMessageListener {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)
    public void input(Message<String> msg) {
        System.out.println("消费者8802： ----->收到消息：" + msg.getPayload() + "\t serverPort:" + serverPort);
    }
}
